<template>
  <div class="organization">
    <el-select
      class="or-select"
      style="width: 97%"
      v-model="value"
      popper-class="or-list"
    >
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
      </el-option>
    </el-select>
    <div class="or-Title">
      <div class="titlecolor"></div>
      <div class="or">
        <h1 class="ortitle">{{ title }}</h1>
      </div>
    </div>
    <template>
      <div class="governmentlist">
        <li
          v-for="{ id, title, link } in Government"
          @click="link1(link)"
          class="government"
          :key="id"
        >
          {{ title }}
        </li>
      </div>
    </template>
    <div class="or-Title">
      <div class="titlecolor"></div>
      <div class="or">
        <h1 class="ortitle">{{ title1 }}</h1>
      </div>
    </div>
    <template>
      <div class="Teachinglist">
        <li
          v-for="{ id, title, link } in Teaching"
          @click="link1(link)"
          class="Teaching"
          :key="id"
        >
          {{ title }}
        </li>
      </div>
    </template>
  </div>
</template>
<script>
import { GovernmentOrganization, TeachingOrganization } from "@/api";
export default {
  name: "Organization",
  data() {
    return {
      options: [
        {
          value: "1",
          label: "党政机构",
        },
        {
          value: "2",
          label: "教学机构",
        },
      ],
      value: this.$route.query.key,
      title: this.$route.query.key,
      title1: this.$route.query.key1,
      Government: [],
      Teaching: [],
    };
  },

  // 挂载时向APP传递事件名称和值
  mounted() {
    this.$emit("organization1", false);
  },
  created() {
    GovernmentOrganization().then((res) => {
      const data = res.data;
      this.Government = data;
      // console.log(data);
    });
    TeachingOrganization().then((res) => {
      const data = res.data;
      this.Teaching = data;
    });
  },
  // 销毁之前向APP传递事件名称和值
  beforeDestroy() {
    this.$emit("organization", true);
  },
  //   watch: {
  //     $route(value) {
  //       this.title = value.query.key;
  //     },
  //   },
  methods: {
    //     change(value) {
    //       let obj = {};
    //       obj = this.options.find((item) => {
    //         return item.value === value;
    //       });
    //       this.value = obj.label;
    //       this.title = this.value;
    //       console.log(this.value);
    //     },
    link1(link) {
      window.location.href = link;
    },
  },
};
</script>
<style>
.organization {
  background: white;
}
.infinite-list-wrapper {
  height: auto;
}
.or-Title {
  width: 96%;
  border-bottom: 1px solid #084fb0;
  margin: 0.2rem;
}
.or {
  display: inline-block;
}
.ortitle {
  font-size: 0.8rem;
  padding: 0.2rem;
  color: #084fb0;
  font-weight: normal;
}
.or-select .el-input__inner {
  height: 1.5rem;
  font-size: 0.72rem;
}
.or-select .el-input__inner {
  text-align: center;
  background: #084fb0;
  color: white;
}
.or-list {
  text-align: center;
  background: rgba(0, 0, 0, 0.75);
}
.el-popper[x-placement^="bottom"] {
  margin: 0;
}
.or-list .el-select-dropdown__item {
  color: white;
  border-bottom: 1px solid #868686;
  font-size: 0.6rem !important;
  height: auto !important;
  line-height: 1.5rem !important;
}
.or-list .el-select-dropdown__item:nth-child(2) {
  border-bottom: 0;
}
.or-list .el-select-dropdown__item.hover {
  background-color: rgba(0, 0, 0, 0.75);
}
.government {
  width: 88%;
  margin-left: 3%;
  margin-top: 0.4rem;
  font-size: 0.6rem;
  color: #666;
  background: #ededed;
  padding-left: 5%;
  line-height: 1.4rem;
  background-repeat: no-repeat;
  background-position-y: center;
}
.governmentlist {
  padding-bottom: 1rem;
}
.Teaching {
  width: 88%;
  margin-left: 3%;
  margin-top: 0.4rem;
  font-size: 0.6rem;
  color: #666;
  background: #ededed;
  padding-left: 5%;
  line-height: 1.4rem;
  background-repeat: no-repeat;
  background-position-y: center;
}
.Teachinglist {
  padding-bottom: 1rem;
}
</style>
